package com.beyond.parse.util;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegUtil {

    public static List<String> regSubstring(String content, String reg) {
        List<String> textList = new ArrayList<String>();

        Pattern pattern = Pattern.compile(reg);
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()) {
            textList.add(matcher.group(1));
        }

        return textList;
    }

    public static boolean isRegContain(String content, String reg) {
        Pattern pattern = Pattern.compile(reg);
        boolean matches = pattern.matcher(content).matches();
        return matches;
    }


    public static void main(String[] args) {
        //boolean regContain = isRegContain("concat('%', '&username&', '%')", "&(.*)&");
        //System.out.println(regContain);

        String str = "@username@1234";
        String pattern = "(.*)@(.*)@(.*)";

        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(str);
        System.out.println(m.matches());
    }
}
